selection: Add surface based apis
authorMatthias Clasen <mclasen@redhat.com>
Sun, 22 Oct 2017 20:19:31 +0000 (22:19 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 22 Oct 2017 20:22:44 +0000 (22:22 +0200)
Add gtk_selection_data_set_surface.

gtk/gtkselection.c
gtk/gtkselection.h

index 00b6f430ca7a3a555c1ad48791dbd4c372519d44..166e29fe8b19fda26c71378e54190e5dbf9e6be0 100644 (file)
@@ -1733,6 +1733,23 @@ gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
   return FALSE;
 }
 
+gboolean
+gtk_selection_data_set_surface (GtkSelectionData *selection_data,
+                               cairo_surface_t  *surface)
+{
+  GdkPixbuf *pixbuf;
+  gboolean retval;
+
+  pixbuf = gdk_pixbuf_get_from_surface (surface,
+                                        0, 0,
+                                        cairo_image_surface_get_width (surface),
+                                        cairo_image_surface_get_height (surface));
+  retval = gtk_selection_data_set_pixbuf (selection_data, pixbuf);
+  g_object_unref (pixbuf);
+
+  return retval;
+}
+
 /**
  * gtk_selection_data_get_pixbuf:
  * @selection_data: a #GtkSelectionData
index 678b3ac7a8260ce94183fefa6ba6f1e8a6ad248b..e151571cf3c27b5158864660cdca3dfc1c8186e5 100644 (file)
@@ -224,6 +224,9 @@ guchar * gtk_selection_data_get_text (const GtkSelectionData     *selection_data
 GDK_AVAILABLE_IN_ALL
 gboolean gtk_selection_data_set_pixbuf   (GtkSelectionData  *selection_data,
                                           GdkPixbuf         *pixbuf);
+GDK_AVAILABLE_IN_3_94
+gboolean gtk_selection_data_set_surface (GtkSelectionData  *selection_data,
+                                         cairo_surface_t   *surface);
 GDK_AVAILABLE_IN_ALL
 GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData  *selection_data);
 GDK_AVAILABLE_IN_ALL